import { yxRequest } from "..";
import type { IResult } from '@/types/common'
import type { IMenuModel } from '@/views/main/authorization/menus/types'
import {IHealthRules} from "@/views/main/health/rule/types";
import {IHealthSuggestions} from "@/views/main/health/suggestions/types";
import {Ref, UnwrapRef} from "vue";
import {IHealthData} from "@/views/main/health/data/types";

/**
 * 健康数据
 * @param current 当前页
 * @param size 显示条数
 */
export function queryDataList(current: number = 1, size: number = 5) {
    return yxRequest.get<IResult>({
        url: '/admin/health/data',
        params: {
            current,
            size
        }
    })
}
/**
 * 删除健康数据
 * @param id 用户ID
 */
export function deleteHealthData(id: number) {
  return yxRequest.delete<IResult>({
    url: '/admin/health/data/' + id
  })
}

/**
 * 健康规则列表
 * @param current 当前页
 * @param size 显示条数
 */
export function queryRulesList(current: number = 1, size: number = 5) {
  return yxRequest.get<IResult>({
    url: '/admin/health/rules',
    params: {
      current,
      size
    }
  })
}

/**
 * 新增健康数据
 * @param healthData 健康规则对象
 */
export function addHealthData(healthData: IHealthData) {
  return yxRequest.post<IResult>({
    url: '/admin/health/data',
    data: healthData
  });
}

/**
 * 修改健康数据
 * @param healthData 健康规则对象
 */
export function updateHealthData(healthData: IHealthData) {
  return yxRequest.put<IResult>({
    url: '/admin/health/data',
    data: healthData
  });
}



/**
 * 新增健康规则
 * @param healthRules 健康规则对象
 */
export function addHealthRules(healthRules: IHealthRules) {
  return yxRequest.post<IResult>({
    url: '/admin/health/rules',
    data: healthRules
  });
}

/**
 * 修改健康规则
 * @param healthRules 健康规则对象
 */
export function updateHealthRules(healthRules: IHealthRules) {
  return yxRequest.put<IResult>({
    url: '/admin/health/rules',
    data: healthRules
  });
}

/**
 * 删除健康规则
 * @param id 健康规则ID
 */
export function deleteHealthRules(id: number) {
  return yxRequest.delete<IResult>({
    url: `/admin/health/rules/${id}`
  });
}


/**
 * 获取全部健康建议列表
 */
export function queryAllSuggestions(current: number = 1, size: number = 5) {
  return yxRequest.get<IResult<IHealthSuggestions[]>>({
    url: '/admin/health/suggestions',
    params: {
      current,
      size,
    }
  });
}

/**
 * 根据ID查询健康建议
 * @param id 健康建议ID
 */
export function querySuggestionById(id: number) {
  return yxRequest.get<IResult<IHealthSuggestions>>({
    url: `/admin/health/suggestions/${id}`
  });
}

/**
 * 根据星级查询健康建议
 * @param stars 星级
 */
export function querySuggestionsByStars(stars: string) {
  return yxRequest.get<IResult<IHealthSuggestions[]>>({
    url: `/admin/health/suggestions/stars/${stars}`
  });
}

/**
 * 新增健康建议
 * @param healthSuggestion 健康建议对象
 */
export function addHealthSuggestion(healthSuggestion: IHealthSuggestions) {
  return yxRequest.post<IResult>({
    url: '/admin/health/suggestions',
    data: healthSuggestion
  });
}

/**
 * 修改健康建议
 * @param healthSuggestion 健康建议对象
 */
export function updateHealthSuggestion(healthSuggestion: IHealthSuggestions) {
  return yxRequest.put<IResult>({
    url: '/admin/health/suggestions',
    data: healthSuggestion
  });
}

/**
 * 删除健康建议
 * @param id 健康建议ID
 */
export function deleteHealthSuggestion(id: number) {
  return yxRequest.delete<IResult>({
    url: `/admin/health/suggestions/${id}`
  });
}

/**
 * 查询评估结果
 * @param id 健康建议ID
 */
export function getEvaluationResult(id: number) {
  return yxRequest.get<IResult<IHealthSuggestions>>({
    url: `/admin/health/data/result/${id}`
  });
}
